﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.Data.SqlClient;

namespace Payroll
{
    public partial class DeleteEmployee : System.Windows.Forms.Form
    {
        public DeleteEmployee()
        {
            InitializeComponent();
        }

        private void DeleteCommissionedEmployee_Load(object sender, EventArgs e)
        {
            string sqlStr;
            string id;
            string connString = @"Data Source=..\..\Database1.sdf";
            SqlCeConnection connection = new SqlCeConnection(connString);
            connection.Open();
            sqlStr = " select id from Summarytable order by id";
            SqlCeCommand cmd = new SqlCeCommand(sqlStr, connection);
            SqlCeDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                id = Convert.ToString(reader[0]);
                Console.WriteLine(id);
                textid.Items.Add(id);
            }
            connection.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int id = int.Parse(textid.Text);
            PayrollDatabase pd = new sytpayrolldatabase();
            DeleteEmployeeTransaction emp = new DeleteEmployeeTransaction(id, pd);
            emp.Execute();

            myFile.myWrite_operate(myUser.Name,"删除员工 id: " + id);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
